package com.jt.service;

import ch.qos.logback.core.joran.conditional.ElseAction;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jt.dao.UserMapper;
import com.jt.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

@Service
public class UserServiceImpl {




    @Autowired
    private UserMapper userMapper;



    public boolean removeById(Serializable id) {
        int i = userMapper.deleteById(id);
        if(i==0){
            return  true;
        }else
            return false;
    }


    public User getOne(int id) {
        User user = userMapper.selectById(id);
        return user;
    }

    public boolean save(User entity) {
        int insert = userMapper.insert(entity);
        if(insert==1)
            return true;
        else
            return  false;
    }


    public List<User> list() {
        List<User> users = userMapper.selectList(null);
        return users;
    }

    public boolean  updateUser(User user) {
        int i = userMapper.updateById(user);
        if(i==1){
            return  true;
        }else{
            return  false;
        }
    }
}
